#include "masterPutCycleSlave.h"
#include "stdlib.h"
int main(){
	uint16_t itera;

	Event initPutCycle;
	Event innerRxEvent={HAND_SHAKE_MACHINE_RX_EVENT_CODE,NULL};
	Event innerTimeOut={HAND_SHAKE_MACHINE_TIMEOUT_EVENT_CODE,NULL};

	PutCycleSlaveInitData ponte;

	uint8_t bufferSpace[100];

	ponte.contentBuffer=&bufferSpace;
	ponte.pPacket=10;
	initPutCycle.signature=INIT_CODE;
	for (itera=0;itera<100;itera++)
		bufferSpace[itera]=0;

	initPutCycle.data=&ponte;
	MasterMachine mean;

	stateMachineOnInit2(&mean, masterPutCycleSlavePacketReceivingState, &initPutCycle); //parti

	for (itera=0;itera<10;itera++){
		mean.microCycleHandler.sizeRx=1;
		mean.microCycleHandler.RxBuffer[0]=(uint8_t)itera;
		stateMachineDispatcher(&mean.microCycleHandler,&innerRxEvent);
	}
	mean.microCycleHandler.sizeRx=0;
	stateMachineDispatcher(&mean.microCycleHandler,&innerRxEvent); //arrivo end
	//secondo test
	stateMachineOnInit2(&mean,masterPutCycleSlavePacketReceivingState,&initPutCycle); //parti

	for (itera=0;itera<10;itera++){
		mean.microCycleHandler.sizeRx=1;
		mean.microCycleHandler.RxBuffer[0]=(uint8_t)itera;
		stateMachineDispatcher(&mean.microCycleHandler,&innerRxEvent);
	}

	for (itera=0;itera<10;itera++)
		stateMachineDispatcher(&mean.microCycleHandler,&innerTimeOut); //caso end perso
	//terzo test
	stateMachineOnInit2(&mean,masterPutCycleSlavePacketReceivingState,&initPutCycle); //parti

	for (itera=0;itera<10;itera++)
			stateMachineDispatcher(&mean.microCycleHandler,&innerTimeOut); //caso comunicazione persa
	while(1)
	{
		;
	}
}
